﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VisualAgile.IBLL;
using VisualAgile.Model;
using System.Collections;

namespace VisualAgile.Web.Tests.Fakes
{

    public class FakeRoleManager : IRoleManager   
    {
        private List<Role> roleList;

        public FakeRoleManager(List<Role> roles)
        {
            roleList = roles;
        }

        /// <summary>
        /// Create a project (back to contain the default value)
        /// </summary>
        /// <returns></returns>
        public Role NewRole()
        {
            var project = new Role();
            
            project.CreateTime = DateTime.Now;            

            return project;
        }

        /// <summary>
        /// Save project
        /// </summary>
        /// <param name="project">Role entity</param>
        /// <returns></returns>
        public Role Save(Role project)
        {
            return null;
        }

        /// <summary>
        /// Access to roles
        /// </summary>
        /// <param name="projectId">Role ID</param>
        /// <returns></returns>
        public Role Get(Guid roleId)
        {
            return roleList.SingleOrDefault(u => u.RoleGUID == roleId);
        }

        /// <summary>
        /// Access to roles
        /// </summary>
        /// <param name="projectId">Role ID</param>
        /// <returns></returns>
        public Role GetByName(string roleName)
        {
            return roleList.SingleOrDefault(u => u.Name == roleName);
        }

        /// <summary>
        /// Access to roles
        /// </summary>
        /// <param name="projectId">Role ID</param>
        /// <returns></returns>
        public Role GetById(int? roleId)
        {
            return roleList.SingleOrDefault(u => u.RoleID == roleId);
        }      

        /// <summary>
        /// Delete Role
        /// </summary>
        /// <param name="projectId">Role ID</param>
        /// <returns></returns>
        public void Delete(Guid projectId)
        {
            
        }

        /// <summary>
        /// Update Role
        /// </summary>
        /// <param name="project">Role Entity</param>
        /// <returns></returns>
        public Role Update(Role project)
        {
            return null;
        }

        /// <summary>
        /// Access to roles
        /// </summary>
        /// <returns></returns>
        public IList GetAll()
        {
            return roleList;
        }

        private void Validate(Role project)
        {
            //TODO throw exception on error.
        }        
    }
}
